package br.com.skytef.pos.beans;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.skytef.entity.TicketWSEntity;
import br.com.skytef.wsdl.Service1Soap;
import br.com.skytef.wsdl.Service1SoapProxy;

@SuppressWarnings("serial")
@WebServlet("/Teste2")
public class ContrTeste2 extends HttpServlet {

	public ContrTeste2() throws Exception {

	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		RequestDispatcher rd;
		try {

			// ///////////////////////////////////////////////////////////////////////
			// String url =
			// "http://kapatron001.dyndns.org:8525/WebServiceKPCaixa/Service1.asmx?op=IncluiTicket";
			String url = "http://kapatron001.dyndns.org:8525/WebServiceKPCaixa/Service1.asmx";
			String result = "";

			// ///////////////////////////////////////////////////////////////////////
			// Executa o metodo 1 hello world
			Service1Soap webservice = new Service1SoapProxy(url);
			result = webservice.helloWorld();

			System.out.println(result);

			// ///////////////////////////////////////////////////////////////////////
			// Executa o metodo 3 incluir ticket
			TicketWSEntity ticket = new TicketWSEntity();
			webservice = new Service1SoapProxy(url);
			result = webservice.incluiTicket(ticket);

			System.out.println(result);

		} catch (Exception e) {
			System.out.println("##>> Erro no Forward Request" + e.getMessage());
			e.printStackTrace();
		}
	}

}
